import matplotlib as mat
import csv
import numpy as np
import matplotlib.pyplot as plt
from math import *
import scipy.io as io

xge=1
yge=1
tmax=1e4
xindex=5
xstep=0.05
yindex=11

ystep=0.3
xlog=True
ylog=False

# % 1  2   3  4   5  6   7   8   9  10 11 12  13  14 15  16  17  18  ----1!!!!!!!!!!!!
# % m1,m2,Lx,ecc0,a,tb0,mt1,mt2,kw,kw2,mx,mx2,eccx,tbx,f,nnn,uuu,m_tr
# % m1,m2,Lx,ecc0,a,tb0,mt1,mt2,kw,kw2,mx,mx2,eccx,tbx,f,m_transferrate,b_iso,m_tr
name='all_Lx39erg_z0.02_rb'
sourcedata=np.load("".join([name,'.npy']))

resultnp=sourcedata
print(len(sourcedata))
leng=len(resultnp)

del sourcedata
kw2=resultnp[:,9]
kw2=kw2.astype(np.int)
NS=np.array([])
BH=np.array([])
for num in range(0,leng):
    if(resultnp[num,9]==13):
        NS=np.r_[NS,resultnp[num,:]]
    if(resultnp[num,9]==14):
        BH=np.r_[BH,resultnp[num,:]]
np.save('all_Lx39erg_z0.02_rb_NS',NS)
np.save('all_Lx39erg_z0.02_rb_BH',BH)
NS=resultnp[kw2==13,:]
BH=resultnp[resultnp[:,9]==14,:]

NS100M=NS[NS[:,6]<100]
NS1G=NS[NS[:,6]>100 & NS[:,6]<1000]
NS10G=NS[NS[:,6]>1000 & NS[:,6]<10000]


# plot figure5  logb with num
b100=NS100M[:,16]
b1=NS1G[:,16]
b10=NS10G[:,16]
w100=NS100M[:,7]-NS100M[:,6]
w1=NS1G[:,7]-NS1G[:,6]
w10=NS10G[:,7]-NS10G[:,6]
plt.figure()



ax1=plt.figure()
plt.loglog(pltxT,tdata[0,:])

plt.loglog(pltxT,tdata[1,:])
# plt.semilogy(y, 'o-', c='orangered',
#             label='semilog')
plt.show()
